
// === uuMeta.attr ===
// depend: uuMeta
/*
uuMeta.attr.get(node, attrs) - return { name: "value", ... }
uuMeta.attr.set(node, hash)
uuMeta.attr.normalize("for") - return "htmlFor"
 */
(function uuMetaAttrScope() {
var _mm = uuMeta,
    _ua = _mm.ua,
    _COMPAT = { href: 1, src: 1 }, // fix a[href^="#"] for IE6, IE7
    _ALIAS = _ua.ie67 ? { "class":   "className",
                          "for":     "htmlFor",
                          colspan:   "colSpan",
                          rowspan:   "rowSpan",
                          accesskey: "accessKey",
                          tabindex:  "tabIndex" }
                      : { "for":     "htmlFor" };

// uuMeta.attr.get - get attribute
function getAttr(node,    // @param Node:
                 attrs) { // @param JointString: "attr" or "attr,attr,..."
                          // @return Hash( { name: "value", ... } ):
  var rv = {}, ary = attrs.split(","), v, i = 0,
      ie = _ua.ie, iemode8 = _ua.iemode8, // alias
      COMPAT = _COMPAT, ALIAS = _ALIAS;

  while ( (v = ary[i++]) ) {
    if (ie) {
      rv[v] = ((iemode8 || COMPAT[v]) ? node.getAttribute(v, 2)
                                      : node[ALIAS[v] || v]) || "";
    } else {
      rv[v] = node.getAttribute(v) || "";
    }
  }
  return rv;
}

// uuMeta.attr.set - set attribute
function setAttr(node,   // @param Node:
                 hash) { // @param Hash: { attrName: attrValue, ... }
  var i, ie67 = _ua.ie67, ALIAS = _ALIAS; // alias

  for (i in hash) {
    node.setAttribute(ie67 ? (ALIAS[i] || i)
                           : i, hash[i]);
  }
}

// uuMeta.attr.normalize - attribute name normalize
//    normalize("for") -> "htmlFor"
function normalize(name) { // @param String: attr name, "for"
                           // @return String: "htmlFor"
  return _ALIAS[name] || name;
}

// --- initialize ---

// --- export ---
uuMeta.attr = {
  get: getAttr,
  set: setAttr,
  normalize: normalize
};

})(); // uuMeta.attr scope

